#ifndef AnimMontageUtils_H
#define AnimMontageUtils_H

#include <QMap>
#include <QString>
#include <QObject>
#include <QVariant>
#include <QVector2D>
#include <QVector3D>
#include <QVector4D>
#include <QQuaternion>
#include <QMetaObject>

class AnimMontageUtils{
public:
    typedef QMap<QString,QObject*> IdMap;

    //获取对象以及子对象的id
    static IdMap groupById(QObject* root);

    static bool isBase(QString className,const QMetaObject* meta);

    template<typename T>
    static inline T inter(const T& v1,const T& v2,float alpha){
        return (1-alpha) * v1 + alpha * v2;
    }

    static QQuaternion inter(const QQuaternion &v1,const QQuaternion &v2,float alpha){
        return QQuaternion::slerp(v1,v2,alpha);
    }
};

class DynamicConnect:public QtPrivate::QSlotObjectBase
{
public:
    typedef std::function<void(QObject* receiver,void **args, bool *ret)> SlotType;
    DynamicConnect():QtPrivate::QSlotObjectBase(&DynamicConnect::FuncImpl){

    }

    static QMetaObject::Connection connect(QObject* source,int signalIndex,QObject* receiver,SlotType slot,Qt::ConnectionType type = Qt::AutoConnection);

    static void FuncImpl(int which, QSlotObjectBase* this_, QObject *receiver, void **args, bool *ret);

    SlotType func;
};

#endif
